import axios from 'axios';

const API_URL = 'http://localhost:8000/api/reports/';

export const getInventoryReport = () => axios.get(`${API_URL}inventory/`);

export const getSalesReport = () => axios.get(`${API_URL}sales/`);
// 下载文件的 API
export const downloadFileApi = (filePath) => {
  const token = localStorage.getItem('access');
  return axios.post(`${API_URL}download_inventory_report/`, { file_path: filePath }, {
    responseType: 'blob', // 确保以二进制形式接收文件
    headers: {
            'Authorization': `Bearer ${token}`, // 注意这里的 Bearer
            'Content-Type': 'application/json',
        },
  });
};